package com.xiejr.actuator.socket.abstracts;

import com.xiejr.actuator.exceptioin.SocketActuatorException;
import lombok.extern.slf4j.Slf4j;

import javax.websocket.CloseReason;
import javax.websocket.Session;
import java.time.LocalDateTime;

/**
 * @program: socket-actuator-spring-boot-starter
 * @description: 普通socket连接
 * @author: xjr
 * @create: 2020-07-09 18:22
 **/
@Slf4j
public abstract class CommonWebsocketHelper extends AbstractWebsocketHelper {

    @Override
    public void message(Session session, String message) throws SocketActuatorException {
        log.info("设备{}发来消息,报文内容:{}",this.ip,message);
        super.refreshHeart(LocalDateTime.now(),message);
    }

    @Override
    public void close(Session session, CloseReason closeReason) throws SocketActuatorException {
        log.info("ip为{}的设备退出socket链接，原因是:{}",this.ip,closeReason.toString());
    }

}
